package com.yuchting.dinneronline.server.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.jdo.PersistenceManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yuchting.dinneronline.server.Config;
import com.yuchting.dinneronline.server.MainServiceImpl;

public class PushTest extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3925808952290276595L;


	public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
		this.doGet(request,response);
	}
	
	public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
		String t_check			= (String)request.getParameter("check");
		
		if(t_check == null){
			return ;
		}else{
				
			response.setCharacterEncoding("utf-8");
			response.setContentType("text/html");
			
			PrintWriter t_writer = response.getWriter();
			
			PersistenceManager t_pm = MainServiceImpl.PMF.get().getPersistenceManager();
			
			try{
				Config t_cfg = MainServiceImpl.getConfigImpl(t_pm);
				
				if(t_check.equals("true")){
					t_writer.print(t_cfg.getPrompt().hashCode());
				}else{		
					t_writer.print("你新看到的内容如下（演示程序）：<br /><br />"+t_cfg.getPrompt());
				}
				
			}catch(Exception e){
				e.printStackTrace(System.err);
			}finally{
				t_pm.close();
			}
		}
	}
}
